package com.ihr360.job.core.step.skip;

public class CompositeSkipPolicy implements SkipPolicy {

    private SkipPolicy[] skipPolicies;

    public CompositeSkipPolicy() {
        this(new SkipPolicy[0]);
    }

    public CompositeSkipPolicy(SkipPolicy[] skipPolicies) {
        this.skipPolicies = skipPolicies;
    }

    public void setSkipPolicies(SkipPolicy[] skipPolicies) {
        this.skipPolicies = skipPolicies;
    }

    @Override
    public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException {
        for (SkipPolicy policy : skipPolicies) {
            if (policy.shouldSkip(t, skipCount)) {
                return true;
            }
        }
        return false;
    }

}